<template>
  <div>
      <!-- <div class="top" >
          <el-input  min="0" max="1" type="number" oninput="this.value=this.value.replace(/[^0-1]/g, '')" style="width: 20%;margin: 10px 10px;" placeholder="请输入身份状态" prefix-icon="el-icon-search" v-model="name" maxlength="20"></el-input>
          <el-button type="primary" icon="el-icon-search" @click="searchName">搜索</el-button>
          <el-button style="float: right;" type="primary" @click="handleAdd">添加<i class="el-icon-upload el-icon--right"></i></el-button>
      </div> -->
      <el-table :data="user" height="700" border stripe style="width: 100%">
        <!-- <el-table-column align="center" prop="id" label="id" width="150"></el-table-column> -->
        <el-table-column align="center" prop="username" label="用户名" width="200"></el-table-column>
        <el-table-column align="center" prop="phone" label="联系电话" width="200"></el-table-column>
        <el-table-column align="center" prop="content" label="反馈内容" width="400"></el-table-column> 
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <!-- <el-button type="primary" icon="el-icon-edit"  @click="handleUpdata(scope.row)"></el-button> -->
            <el-button type="primary" icon="el-icon-s-check"  @click="handleDel(scope.row)">解决</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- <el-dialog :visible.sync="addVisible" :modal-append-to-body="false" width="60%" top="0" title="新增" :before-close="Close" >
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="用户名" prop="username">
              <el-input  v-model="ruleForm.username" ></el-input>
            </el-form-item>
            <el-form-item label="账号" prop="phone">
              <el-input  v-model="ruleForm.phone" ></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
              <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="确认密码" prop="checkPassword">
              <el-input type="password" v-model="ruleForm.checkPassword" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="性别" prop="sex">
              <el-radio-group v-model="ruleForm.sex">
                <el-radio  label="男">男</el-radio>
                <el-radio label="女">女</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="员工？" prop="isAdmin">
              <el-radio-group v-model="ruleForm.isAdmin">
                <el-radio  label="1">是</el-radio>
                <el-radio label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="个性签名" prop="sign">
              <el-input  v-model="ruleForm.sign" ></el-input>
            </el-form-item>
            <el-form-item label="图片" prop="avatar">
              <el-upload class="avatar-uploader"  action="http://127.0.0.1:3000/v1/upload/upload" :show-file-list="false" :on-success="handleAvatarSuccess"  >
                <img style="width: 200px" v-if="imageUrl" :src="imageUrl" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="addReset('ruleForm')">重置</el-button>
          <el-button type="primary" @click=" add('ruleForm')">提交</el-button>
        </span>
      </el-dialog> -->

  </div>

</template>

<script>
import myaxios from '../http/MyAxios'
import { BASE_URL } from '@/config'
  export default {
    data() {
            
      var Pass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else {
          if (this.ruleForm.checkPassword !== '') {
            this.$refs.ruleForm.validateField('checkPassword');
          }
          callback();
        }
      };
      var Pass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请再次输入密码'));
        } else if (value !== this.ruleForm.password) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
      };
      return {
        user:[],
        id:0,
        name:'',
        imageUrl: '',
        addVisible: false,
        updataVisible:false,
        form:[],
        ruleForm: {
          userId:'',
          id:'',
          username:'',
          phone: '',
          content:''
         
        },
        rules:{
          // isAdmin:[
          // {required:true,message:'该字段必填',trigger:'blur'},
          // ],
          // sex:[
          // {required:true,message:'该字段必填',trigger:'blur'},
          // ],
          // sign:[
          // {required:true,message:'该字段必填',trigger:'blur'},
          // ],
          // username:[
          // {required:true,message:'该字段必填',trigger:'blur'},
          // ],
          // phone:[
          //   {required:true,message:'该字段必填',trigger:'blur'},
          //   {
          //     pattern:/^1[3-9]\d{9}$/,
          //     message:'手机号格式不正确',
          //     trigger:'blur'
          //   }
          // ],
          // password:[
          //   {required:true,message:'该字段必填',trigger:'blur'},
          //   {min:6,max:9,message:'长度6-9',trigger:'blur'},
          //   { validator: Pass, trigger: 'blur' }
           
          // ],
          // checkPassword:[
          //   {required:true,message:'该字段必填',trigger:'blur'},
          //   { validator: Pass2, trigger: 'blur' }
          // ]
        }
      }
    },
    beforeMount(){
      this.getUser()
    },
    methods: {
      handleAvatarSuccess(res) {
        this.imageUrl = res.result;

      },
 
      handleDel(row) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let url=BASE_URL + '/v1/after/afterdel'
          let params = {id:row.id}
            myaxios.get(url,params).then(()=>{
                this.$message({
                  type: 'success',
                  message: '删除成功!'
                });
                this.getUser()
              }).catch(err=>{
                    console.warn(err);
                 })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
      Close(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },

      getUser(){
        let url=BASE_URL + '/v1/after/afterSearch'
        myaxios.get(url).then(res=>{
          this.user = res.data.data
        }).catch(err=>{
          console.warn(err);
        })
    },
    },
  }
</script>
<style scoped lang="scss">

</style>